import {Restivus} from 'meteor/nimble:restivus';
import {Meteor} from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { FS } from 'meteor/cfs:base-package';
import base64 from 'base-64';
if (Meteor.isServer) {
  /*  Meteor.startup(() => {
        let Api = new Restivus({
            useDefaultAuth: true,
            prettyJson: true,
        });
        let Images = new FS.Collection("images", {
            stores: [
                new FS.Store.FileSystem("images", {path: '~/uploads'})
            ]
        });
        // 上传用户头像
        Api.addRoute('uploadPhoto', {authRequired: false}, {
            post: {
                action() {
                    if (this.bodyParams) {
                        const param = this.bodyParams;
                        // console.log('param : ',param);
                        const token = param.token;
                        const file = param.file;
                        const user = Meteor.users.findOne({"services.resume.loginTokens.token":token});
                        if(user) {
                            if(file){
                                console.log('file : ', file);
                                const i = base64.decode(file);
                                console.log('i ==== ', new Image(i));
                                const img = Images.insert(new Image(i), function (err, fileObj) {
                                    // console.log('-------');
                                    console.log('err : ', err);
                                    // console.log('fileObj : ', fileObj);
                                });
                                console.log('img : ', img);
                            }
                        }else{
                            return {success: false, result: '未获取到登录用户的信息！', resultCode: 1002};
                        }
                    }
                    return {success: false, result: '没有填写信息！', resultCode: 1002};
                }
            }
        });
    });*/
}